﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/SacNetUG.Master" Inherits="System.Web.Mvc.ViewPage<SacNetUG.Models.Event>" %>
<%@ Import Namespace="SacNetUG.Models" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Edit Event
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <script src="../../Scripts/MicrosoftMvcAjax.js" type="text/javascript"></script>
    <h2>
        Edit Event</h2>
    <% Html.EnableClientValidation(); %>
    <% using (Html.BeginForm())
       {%>
    <%= Html.HiddenFor(model => model.EventId) %>
    <table>
        <%= Html.ValidatedEditorFor(model => model.Name)%>
        <%= Html.ValidatedEditorFor(model => model.StartDate)%>
        <tr>
            <td>
                <%= Html.LabelFor(model => model.Location) %>
            </td>
            <td>
                <%= Html.NullableDropDownListFor(model => model.LocationId, "Locations", "LocationId", "Name", true)%>
                <%= Html.ValidationMessageFor(model => model.LocationId) %>
            </td>
        </tr>
        <%= Html.ValidatedCkEditorFor(model => model.Description)%>
        <tr>
            <td>
            </td>
            <td>
                <input type="submit" value="Submit" />
            </td>
        </tr>
    </table>
    <% } %>
    
    <h3>Speakers</h3>
<%--    <% Html.RenderPartial("EventPresenterEdit", Model); %>--%>

<div id="presenterDiv">
   <% using (Ajax.BeginForm("AddPresenter", new {controller = "Event", id = Model.EventId},
                          new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "presenterDiv" }))
      { %>    
    <table>
        
        <% foreach (var presenter in Model.EventPresenters ) { %>
            <tr>
                <td>
                    <%--<%= Html.ActionLink("Remove","RemovePresenter") %>--%>
                    <%= Ajax.ActionLink("Remove","RemovePresenter",
                        new {eventId=Model.EventId, userId=presenter.UserId},new AjaxOptions{ UpdateTargetId="presenterDiv"}) %>
                </td>
                <td>
                    <%= presenter.User.Name %>
                </td>
           </tr>
        <% } %>
        <tr id="newPresenter" style="display:none">
            <td colspan="2">
                <%= Html.DropDownList("presenterList", ViewData["presenterList"] as SelectList, "Select a Presenter") %>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <button id="addPresenter" type="button" onclick="addPresenterClick()" value="AddPresenter" name="AddPresenter">Add Speaker</button>
                <%--<button id="pOk" type="button" onclick="addSponsor" value="Ok" name="pOk" style="display:none">Ok</button>--%>
                <input id="pOk" type="submit" value="Ok" style="display:none" />
                <button id="pCancel" type="button" onclick="addPresenterCancel()" value="Cancel" name="pCancel" style="display:none" >Cancel</button>
            </td>
        </tr>
    </table>
    <% } %>
</div>



    <h3>Sponsors</h3>
    <% Html.RenderPartial("EventSponsorEdit", Model); %>
    
    <div>
        <%=Html.ActionLink("Back to List", MVC.Event.Index(1)) %>
    </div>
    

    <script type="text/javascript">

        function addSponsorClick() {
            document.getElementById("addSponsor").setAttribute("style", "display:none");
            document.getElementById("sOk").setAttribute("style", "display:inline");
            document.getElementById("sCancel").setAttribute("style", "display:inline");
            document.getElementById("newSponsor").setAttribute("style", "display:inline");
        }

        function addPresenterClick() {
            document.getElementById("addPresenter").setAttribute("style", "display:none");
            document.getElementById("pOk").setAttribute("style", "display:inline");
            document.getElementById("pCancel").setAttribute("style", "display:inline");
            document.getElementById("newPresenter").setAttribute("style", "display:inline");
        }
        function addSponsorCancel() {
            document.getElementById("addSponsor").setAttribute("style", "display:inline");
            document.getElementById("sOk").setAttribute("style", "display:none");
            document.getElementById("sCancel").setAttribute("style", "display:none");
            document.getElementById("newSponsor").setAttribute("style", "display:none");
        }
        function addPresenterCancel() {
            document.getElementById("addPresenter").setAttribute("style", "display:inline");
            document.getElementById("pOk").setAttribute("style", "display:none");
            document.getElementById("pCancel").setAttribute("style", "display:none");
            document.getElementById("newPresenter").setAttribute("style", "display:none");
        }
    </script>

</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="head" runat="server">
<%--    <script src="../../Scripts/MicrosoftAjax.js" type="text/javascript"></script>--%>


</asp:Content>
